{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "%matplotlib nbagg\n",
    "import numpy as np\n",
    "import matplotlib\n",
    "import matplotlib.pyplot as plt\n",
    "import glob\n",
    "import math"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "class SymmetryFunctionData:\n",
    "    def __init__(self):\n",
    "        self.parameters = {}\n",
    "        self.histogram = []\n",
    "\n",
    "def readSymmetryFunctionHistogram(file_name):\n",
    "    sfd = SymmetryFunctionData()\n",
    "    f = open(file_name, \"r\")\n",
    "    for line in f:\n",
    "        split_line = line.split()\n",
    "        if split_line[0] == \"#SFINFO\":\n",
    "            sfd.parameters[split_line[1]] = split_line[2]\n",
    "        elif split_line[0][0] == \"#\":\n",
    "            continue\n",
    "        else:\n",
    "            sfd.histogram.append([float(split_line[0]),\n",
    "                                  float(split_line[1]),\n",
    "                                  float(split_line[2])])\n",
    "    f.close()\n",
    "    sfd.histogram = np.array(sfd.histogram).T\n",
    "    return sfd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "sf_histograms = []\n",
    "for file_name in sorted(glob.glob(\"sf.*.histo\")):\n",
    "    sf_histograms.append(readSymmetryFunctionHistogram(file_name))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true,
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "for sfh in sf_histograms:\n",
    "    print sfh.parameters[\"type\"], sfh.parameters[\"index\"]\n",
    "    fig = plt.figure()\n",
    "    ax = fig.add_subplot(111)\n",
    "    X = (sfh.histogram[0] + sfh.histogram[1]) / 2.\n",
    "    ax.plot(X, sfh.histogram[2])\n",
    "    mean = float(sfh.parameters[\"mean\"])\n",
    "    sigma = float(sfh.parameters[\"sigma\"])\n",
    "    ax.plot([mean - sigma, mean + sigma], [0, 0], \"-\", lw=3)\n",
    "    ax.plot(mean, 0, \"o\")\n",
    "    ax.plot(float(sfh.parameters[\"min\"]), 0, \"o\")\n",
    "    ax.plot(float(sfh.parameters[\"max\"]), 0, \"o\")"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
